package com.matrix.java.chap_05;

import java.util.Scanner;

/*
    财务应用程序：计算CD价值
 */
public class Ex5_31 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.print("Enter the initial deposit amount: ");
        double amount = input.nextDouble();
        System.out.print("Enter annual percentage yield: ");
        double yearRate = input.nextDouble();
        System.out.print("Enter maturity period (number of months): ");
        int monthNum = input.nextInt();
        input.close();

        System.out.println("Month CD Value");
        double monthRate = yearRate / 1200;
        for (int i = 1; i <= monthNum; i++) {
            amount = amount * (monthRate + 1);
            System.out.printf("%d%s%.2f%n", i, "    ", amount);
        }
    }
}
